package com.gaara.test;

import com.gaara.ddp.R;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

public class MyRes {

	
	private static MyRes myRes;
	public static MyRes getInstance(){
		if(myRes == null){
			myRes = new MyRes();
		}

		return myRes;
	}
	public MyRes() {
		
	}
	
	public MyView view;

	final int caseWidth = 56;
	
    //选择框
	private Bitmap cursor0;
	
	public void setCursor0(Bitmap cursor0) {
		this.cursor0 = cursor0;
	}
	public Bitmap getCursor0() {
		return cursor0;
	}
	
	//球的数量
	public int ballNum = 7;
	
	//气球数组
	private Bitmap[] block = new Bitmap[ballNum];
	
	
	public Bitmap[] getBlock() {
		return block;
	}
	public void setBlock(Bitmap[] block) {
		this.block = block;
	}
	
	//初始化
	public void init(MyView view){
		this.view = view;
		
		loadBitmap();
	}
    
	public void loadBitmap(){
		Resources re = this.view.getResources();
		setCursor0(loadBall(re.getDrawable(R.drawable.cursor0)));
		block[0] = loadBall(re.getDrawable(R.drawable.ball0));
		block[1] = loadBall(re.getDrawable(R.drawable.ball1));
		block[2] = loadBall(re.getDrawable(R.drawable.ball2));
		block[3] = loadBall(re.getDrawable(R.drawable.ball3));
		block[4] = loadBall(re.getDrawable(R.drawable.ball4));
		block[5] = loadBall(re.getDrawable(R.drawable.ball5));
		block[6] = loadBall(re.getDrawable(R.drawable.ball6));
	}
	
	public Bitmap loadBall(Drawable tile){
		Bitmap bitmap = Bitmap.createBitmap(caseWidth, caseWidth, Bitmap.Config.ARGB_8888);
		Canvas canvas = new Canvas(bitmap);
		tile.setBounds(0, 0, caseWidth, caseWidth);
		tile.draw(canvas);
		return  bitmap;
	}

}
